import React from "react";
import {withRouter} from "react-router-dom";
import {inject, observer} from "mobx-react";
import {WrAlertPage, WrFeedback} from "../../../public";
import { Bubble, Tools} from "weaver-mobile";
import {TabPage} from "weaver-mobile-page";
import AccessHeader from "./header";
import { toJS } from "mobx";

const getLabel = Tools.getLabel;

/**
 * 评分-意见反馈
 */
@inject("accessViewStore")
@withRouter
@observer
export default class Feedback extends React.Component {

    constructor(props) {
        super(props);
        this.store = this.props.accessViewStore;
    }

    componentWillMount() {
        this.store.getAccessFbInfo({});
    }

    render() {
        const {canedit, msg, feedBackStore, fbInfoList, getAccessFbInfo} = this.store;
        if (msg == "noinfo") {
            return <WrAlertPage height={"100vh"} show msg={getLabel(508609, "您暂时无权限查看此数据")}/>
        }
        return [
            <AccessHeader showMsg={getLabel(33956,"意见反馈")}/>,
            <div className="roll">
                <WrFeedback
                    fbList={toJS(fbInfoList)}
                    fbReplyStore={feedBackStore}
                    onSubmit={(datas) => {
                        const {text} = datas
                        if (text) {
                            getAccessFbInfo({content: text, operation: "save"});
                        } else {
                            Bubble.warning(getLabel(508896, "反馈内容不能为空"));
                        }
                    }}/>
            </div>
        ]
    }
}